/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.CustomerManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.thread.DeleteCustomerThread;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import javax.servlet.RequestDispatcher;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class DeleteCustomer extends AbstractAction
/*    */ {
/* 22 */   private static Logger logger = Logger.getLogger(DeleteCustomer.class
/* 23 */     .getName());
/*    */ 
/* 25 */   private int id = 0;
/* 26 */   private String indexPath = null;
/*    */ 
/*    */   public DeleteCustomer(AbstractHttpServlet servlet, String id, String indexPath)
/*    */   {
/* 30 */     super(servlet);
/* 31 */     this.id = Util.str2Int(id);
/* 32 */     this.indexPath = indexPath;
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException
/*    */   {
/* 38 */     User loginUser = getLoginUser(request);
/* 39 */     if (!loginUser.isCanDelete()) {
/* 40 */       request.getRequestDispatcher("/nopermission.jsp").forward(
/* 41 */         request, response);
/* 42 */       return;
/*    */     }
/*    */ 
/* 45 */     String ip = Util.getClientIpAddr(request);
/* 46 */     logger.warn("ip:" + ip + " / 用户Id：" + loginUser.userId + " /  用户名：" + 
/* 47 */       loginUser.name + ", 删除了公司：id： " + this.id);
/*    */ 
/* 49 */     CustomerManager manager = new CustomerManager();
/*    */     try {
/* 51 */       manager.deleteCustomer(this.id, loginUser.isAdmin, 
/* 52 */         loginUser.userId, loginUser.companyId);
/*    */ 
/* 55 */       new Thread(new DeleteCustomerThread(this.indexPath)).start();
/*    */     }
/*    */     catch (DBException e) {
/* 58 */       logger.warn(e);
/*    */     }
/* 60 */     response.sendRedirect(request.getContextPath() + "/parties");
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.DeleteCustomer
 * JD-Core Version:    0.6.1
 */